﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WebUI.Models
{
    public class Dates
    {
        public String date;
        public TimeSpan Monday;

        private Day[] _days;

        public Dates(Day[] days)
        {
            _days = days;
        }

        public Dates()
        {
            var values = Enum.GetValues(typeof(DayOfWeek));
            _days = new Day[values.Length];
            int count = 0;
            foreach (var day in values)
            {
                _days[count] = new Day(((DayOfWeek)values.GetValue(count)), TimeSpan.Zero, TimeSpan.Zero);
                count++;
            }
        }

        public Day this[int index]
        {
            get
            {
                if (index < 0 || index >= _days.Length)
                    throw new IndexOutOfRangeException();

                return _days[index];
            }
        }

        public Day this[DayOfWeek day]
        {
            get { return _days[(int)day]; }
        }

        public int Count
        {
            get { return _days.Length; }
        }

        public struct Day
        {
            private DayOfWeek _dayOfWeek;
            private TimeSpan _end;
            private TimeSpan _start;

            public Day(DayOfWeek name, TimeSpan startTime, TimeSpan endTime)
            {
                _dayOfWeek = name;
                _start = startTime;
                _end = endTime;
            }

            public string Name
            {
                get { return _dayOfWeek.ToString(); }
            }

            public DayOfWeek DayOfWeek
            {
                get { return _dayOfWeek; }
                set { _dayOfWeek = value; }
            }

            public TimeSpan Start
            {
                get { return _start; }
                set { _start = value; }
            }

            public TimeSpan End
            {
                get { return _end; }
                set { _end = value; }
            }
        }
    }
}